/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.anniversary.service.impl;

import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.anniversary.domain.StudentTeacherStatistic;
import me.zhengjie.modules.anniversary.repository.StatisticsInfoRepository;
import me.zhengjie.modules.anniversary.repository.StudentTeacherStatisticRepository;
import me.zhengjie.modules.anniversary.service.StatisticsInfoService;
import me.zhengjie.modules.anniversary.service.dto.StatisticsInfoDto;
import me.zhengjie.modules.anniversary.service.dto.StudentTeacherStatisticDto;
import me.zhengjie.modules.anniversary.service.mapstruct.StatisticsInfoMapper;
import me.zhengjie.modules.anniversary.service.mapstruct.StudentTeacherStatisticMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @website https://el-admin.vip
* @description 服务实现
* @author Jiayin Wei
* @date 2020-07-27
**/
@Service
@RequiredArgsConstructor
public class StatisticsInfoImpl implements StatisticsInfoService {

    private final StatisticsInfoRepository statisticsInfoRepository;
    private final StatisticsInfoMapper statisticsInfoMapper;
    private final StudentTeacherStatisticRepository studentTeacherStatisticRepository;
    private final StudentTeacherStatisticMapper studentTeacherStatisticMapper;

    @Override
    public List<StatisticsInfoDto> gender(String college) {
        if(college.trim().isEmpty())
            return statisticsInfoMapper.toDto(statisticsInfoRepository.gender());
        else
            return statisticsInfoMapper.toDto(statisticsInfoRepository.genderByCollege(college.trim()));
    }

    @Override
    public List<StatisticsInfoDto> nation(String college, Integer top) {
        if(college.trim().isEmpty())
            return statisticsInfoMapper.toDto(statisticsInfoRepository.nation(top));
        else
            return statisticsInfoMapper.toDto(statisticsInfoRepository.nationByCollege(college.trim(), top));
    }

    @Override
    public List<StatisticsInfoDto> political(String college, Integer top) {
        if(college.trim().isEmpty())
            return statisticsInfoMapper.toDto(statisticsInfoRepository.political(top));
        else
            return statisticsInfoMapper.toDto(statisticsInfoRepository.politicalByCollege(college.trim(), top));
    }
    @Override
    public List<StatisticsInfoDto> genderTeacher() {
        return statisticsInfoMapper.toDto(statisticsInfoRepository.genderTeacher());
    }

    @Override
    public List<StatisticsInfoDto> nationTeacher(Integer top) {
        return statisticsInfoMapper.toDto(statisticsInfoRepository.nationTeacher(top));
    }

    @Override
    public List<StatisticsInfoDto> politicalTeacher(Integer top) {
        return statisticsInfoMapper.toDto(statisticsInfoRepository.politicalTeacher(top));
    }

    @Override
    public List<StatisticsInfoDto> industryTeacher(Integer top) {
        return statisticsInfoMapper.toDto(statisticsInfoRepository.industryTeacher(top));
    }

    @Override
    public List<StatisticsInfoDto> deptTeacher(Integer top) {
        return statisticsInfoMapper.toDto(statisticsInfoRepository.deptTeacher(top));
    }

    @Override
    public List<StudentTeacherStatisticDto> stuTeacherIncreased(Integer top) {
        return studentTeacherStatisticMapper.toDto(studentTeacherStatisticRepository.statistics(top));
    }
}
